package client.states;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;

import client.Creature;
import client.IGameState;
import client.Player;
import client.StateContext;

import com.jpemartin.jgt.KeyboardStatus;

public class ViewCreaturesScreen implements IGameState {

	private Player player;
	private int selectedIndex = 0;

	public ViewCreaturesScreen(Player player) {
		this.player = player;
	}

	@Override
	public void paint(Graphics g, StateContext stateContext, int GameTime) {
		g.setColor(Color.CYAN);
		g.fillRect(200, selectedIndex * 50, 200, 50);
		g.setColor(Color.DARK_GRAY);
		int y = 0;
		for (Creature c : player.getCreatures()) {
			c.displayQuickStats(g, 200, y);
			y += 50;
		}
		
	}

	@Override
	public void processKeyHit(StateContext stateContext, KeyboardStatus status) {
		if (status.key[KeyEvent.VK_RIGHT]) {
			if (selectedIndex < player.getCreatures().size()-1) {
				selectedIndex++;
				status.key[KeyEvent.VK_RIGHT] = false;
			}
		}
		if (status.key[KeyEvent.VK_DOWN]) {
			if (selectedIndex < player.getCreatures().size()-1) {
				selectedIndex++;
				status.key[KeyEvent.VK_DOWN] = false;
			}
		}
		if (status.key[KeyEvent.VK_LEFT]) {
			if (selectedIndex > 0) {
				selectedIndex--;
				status.key[KeyEvent.VK_LEFT] = false;
			}
		}
		if (status.key[KeyEvent.VK_UP]) {
			if (selectedIndex > 0) {
				selectedIndex--;
				status.key[KeyEvent.VK_UP] = false;
			}
		}
	}

}
